| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | List of all members
nkMemory::BufferView< T > Class Template Reference

A view over data. More...

## Public Member Functions
| BufferView () noexcept
| BufferView (T *data, unsigned long long size) noexcept
| BufferView (const Buffer &buffer) noexcept
| BufferView (const Buffer &buffer, unsigned long long index, unsigned long long length=0) noexcept
| BufferView (Buffer &&buffer)=delete
T * | getData () const
unsigned long long | getSize () const
unsigned long long | getByteSize () const bool empty() const
T & | front ()
const T & | front () const
T & | back ()
const T & | back () const
T * | begin ()
const T * | begin () const
T * | end ()
const T * | end () const
BufferView< T > | subView (unsigned long long index, unsigned long long length=0) const
T & | operator[] (unsigned long long index)
const T & | operator[] (unsigned long long index) const
BufferView< T > & | operator= (const BufferView< T > &other) noexcept
BufferView< T > & | operator= (BufferView< T > &&other) noexcept
template<typename U >
| BufferView (const BufferCast< U > &bufferCast) noexcept
| BufferView (const BufferCast< T > &bufferCast) noexcept
template<typename U >
| BufferView (const BufferView< U > &view) noexcept
| BufferView (const BufferView< T > &view) noexcept
| BufferView (BufferView< T > &&other) noexcept
template<typename U , std::size_t S>
| BufferView (std::array< U, S > &array) noexcept
template<std::size_t S>
| BufferView (std::array< T, S > &array) noexcept
template<typename U >
| BufferView (std::vector< U > &vec) noexcept
| BufferView (std::vector< T > &vec) noexcept
template<typename U , std::size_t S, typename = std::enable_if<std::is_const<T>::value>>
| BufferView (const std::array< U, S > &array) noexcept
template<std::size_t S, typename = std::enable_if<std::is_const<T>::value>>
| BufferView (const std::array< typename std::remove_const< T >::type, S > &array) noexcept
template<typename U , typename = std::enable_if<std::is_const<T>::value>>
| BufferView (const std::vector< U > &vec) noexcept
template<typename = std::enable_if<std::is_const<T>::value>>
| BufferView (const std::vector< typename std::remove_const< T >::type > &vec) noexcept
| operator Buffer () const
template<typename U = T>
| operator BufferCast< U > () const

## Detailed Description

### template<typename T = unsigned char>
class nkMemory::BufferView< T >

A view over data.

Behaves like the BufferCast, but not considered as owner of the memory. This means this variant of the buffer is a good candidate when exchanging data, as it doesn't copy anything but only offers a view over it.

It also allows to cast the data, and alter the way it is intepreted.

## Constructor & Destructor Documentation

## ◆ BufferView() [1/18]

template<typename T = unsigned char>

nkMemory::BufferView< T >::BufferView | ( |  | ) |
| noexcept

Default constructor. Creates an empty view.

## ◆ BufferView() [2/18]

template<typename T = unsigned char>

nkMemory::BufferView< T >::BufferView | ( | T * | data,
|  | unsigned long long | size
| ) |  |
| noexcept

Raw data constructor. This will make the view point to the data provided.

Parameters

  data | The data to point to.
  size | The size of the data provided.

## ◆ BufferView() [3/18]

template<typename T = unsigned char>

nkMemory::BufferView< T >::BufferView | ( | const Buffer & | buffer | ) |
| noexcept

Buffer constructor. Offers a view over the data of a buffer.

Parameters

  buffer | The buffer which memory has to be pointed.

## ◆ BufferView() [4/18]

template<typename T = unsigned char>

nkMemory::BufferView< T >::BufferView | ( | const Buffer & | buffer,
|  | unsigned long long | index,
|  | unsigned long long | length = `0`
| ) |  |
| noexcept

Buffer sub-part constructor. Offers a view over a sub-part of a buffer.

Parameters

  buffer | The buffer which memory has to be pointed.
  index | The starting offset, in number of elements T, at which the view should start.
  length | The number of elements T the sub-view should have.

## ◆ BufferView() [5/18]

template<typename T = unsigned char>

nkMemory::BufferView< T >::BufferView | ( | Buffer && | buffer | ) |
| delete

This destructor is deleted, as a Buffer&& will clean up its memory right after assignment. This is unsafe as the new view's memory will be invalid.

Parameters

  buffer | The rvalue buffer.

## ◆ BufferView() [6/18]

template<typename T = unsigned char>
template<typename U >

nkMemory::BufferView< T >::BufferView | ( | const BufferCast< U > & | bufferCast | ) |
| noexcept

Utility constructor over casts of different type.

Parameters

  bufferCast | The buffer cast which data should be pointed.

## ◆ BufferView() [7/18]

template<typename T = unsigned char>

nkMemory::BufferView< T >::BufferView | ( | const BufferCast< T > & | bufferCast | ) |
| noexcept

Utility constructor over casts of the same type.

Parameters

  bufferCast | The buffer cast which data should be pointed.

## ◆ BufferView() [8/18]

template<typename T = unsigned char>
template<typename U >

nkMemory::BufferView< T >::BufferView | ( | const BufferView< U > & | view | ) |
| noexcept

Utility constructor over a view of another type, reinterpreting the data.

Parameters

  view | The view to reinterpret.

## ◆ BufferView() [9/18]

template<typename T = unsigned char>

nkMemory::BufferView< T >::BufferView | ( | const BufferView< T > & | view | ) |
| noexcept

Utility copy constructor.

Parameters

  view | The view to copy.

## ◆ BufferView() [10/18]

template<typename T = unsigned char>

nkMemory::BufferView< T >::BufferView | ( | BufferView< T > && | other | ) |
| noexcept

Move constructor.

Parameters

  other | The view to move over.

## ◆ BufferView() [11/18]

template<typename T = unsigned char>
template<typename U , std::size_t S>

nkMemory::BufferView< T >::BufferView | ( | std::array< U, S > & | array | ) |
| noexcept

Utility constructor over an array which memory will be reinterpreted to another type.

Parameters

  array | The array which data should be referenced.

## ◆ BufferView() [12/18]

template<typename T = unsigned char>
template<std::size_t S>

nkMemory::BufferView< T >::BufferView | ( | std::array< T, S > & | array | ) |
| noexcept

Utility constructor over an array.

Parameters

  array | The array which data should be referenced.

## ◆ BufferView() [13/18]

template<typename T = unsigned char>
template<typename U >

nkMemory::BufferView< T >::BufferView | ( | std::vector< U > & | vec | ) |
| noexcept

Utility constructor over a vector which memory will be reinterpreted to another type.

Parameters

  vec | The vector which data should be reinterpreted.

## ◆ BufferView() [14/18]

template<typename T = unsigned char>

nkMemory::BufferView< T >::BufferView | ( | std::vector< T > & | vec | ) |
| explicit noexcept

Utility constructor over vectors.

Parameters

  vec | The vector which data should be referenced.

## ◆ BufferView() [15/18]

template<typename T = unsigned char>
template<typename U , std::size_t S, typename = std::enable_if<std::is_const<T>::value>>

nkMemory::BufferView< T >::BufferView | ( | const std::array< U, S > & | array | ) |
| noexcept

Utility reinterpreting constructor over a const array.

Parameters

  array | The array which data should be reinterpreted.

Remarks
  This constructor is only enabled if the view is pointing over a const T (ensuring memory will not be altered).

## ◆ BufferView() [16/18]

template<typename T = unsigned char>
template<std::size_t S, typename = std::enable_if<std::is_const<T>::value>>

nkMemory::BufferView< T >::BufferView | ( | const std::array< typename std::remove_const< T >::type, S > & | array | ) |
| noexcept

Utility reinterpreting constructor over a const array.

Parameters

  array | The array which data should be referenced.

Remarks
  This constructor is only enabled if the view is pointing over a const T (ensuring memory will not be altered).

## ◆ BufferView() [17/18]

template<typename T = unsigned char>
template<typename U , typename = std::enable_if<std::is_const<T>::value>>

nkMemory::BufferView< T >::BufferView | ( | const std::vector< U > & | vec | ) |
| noexcept

Utility reinterpreting constructor over a const vector.

Parameters

  vec | The vector which data should be reinterpreted.

Remarks
  This constructor is only enabled if the view is pointing over a const T (ensuring memory will not be altered).

## ◆ BufferView() [18/18]

template<typename T = unsigned char>
template<typename = std::enable_if<std::is_const<T>::value>>

nkMemory::BufferView< T >::BufferView | ( | const std::vector< typename std::remove_const< T >::type > & | vec | ) |
| noexcept

Utility vector constructor, const version.

Parameters

  vec | The vector which data should be referenced.

Remarks
  This constructor is only enabled if the view is pointing over a const T (ensuring memory will not be altered).

## Member Function Documentation

## ◆ getData()

template<typename T = unsigned char>

T* nkMemory::BufferView< T >::getData | ( |  | ) | const

Returns
  The pointer over the internal data.

## ◆ getSize()

template<typename T = unsigned char>

unsigned long long nkMemory::BufferView< T >::getSize | ( |  | ) | const

Returns
  The size of the buffer, in number of elements.

## ◆ getByteSize()

template<typename T = unsigned char>

unsigned long long nkMemory::BufferView< T >::getByteSize | ( |  | ) | const

Returns
  The size of the buffer, in bytes.
  Whether the buffer is empty (true) or not (false). An empty buffer has a size of 0.

## ◆ front() [1/2]

template<typename T = unsigned char>

T& nkMemory::BufferView< T >::front | ( |  | ) |

Returns
  A reference over the first element of the buffer.

## ◆ front() [2/2]

template<typename T = unsigned char>

const T& nkMemory::BufferView< T >::front | ( |  | ) | const

Returns
  A reference over the first element of the buffer.

## ◆ back() [1/2]

template<typename T = unsigned char>

T& nkMemory::BufferView< T >::back | ( |  | ) |

Returns
  A reference over the last element of the buffer.

## ◆ back() [2/2]

template<typename T = unsigned char>

const T& nkMemory::BufferView< T >::back | ( |  | ) | const

Returns
  A reference over the last element of the buffer.

## ◆ begin() [1/2]

template<typename T = unsigned char>

T* nkMemory::BufferView< T >::begin | ( |  | ) |

Returns
  A pointer over the beginning of the memory spot.

## ◆ begin() [2/2]

template<typename T = unsigned char>

const T* nkMemory::BufferView< T >::begin | ( |  | ) | const

Returns
  A pointer over the beginning of the memory spot.

## ◆ end() [1/2]

template<typename T = unsigned char>

T* nkMemory::BufferView< T >::end | ( |  | ) |

Returns
  A pointer right past the end of the memory spot.

## ◆ end() [2/2]

template<typename T = unsigned char>

const T* nkMemory::BufferView< T >::end | ( |  | ) | const

Returns
  A pointer right past the end of the memory spot.

## ◆ subView()

template<typename T = unsigned char>

BufferView<T> nkMemory::BufferView< T >::subView | ( | unsigned long long | index,
|  | unsigned long long | length = `0`
| ) |  | const

Allows to create a view over a subpart of current view.

Parameters

  index | The new view's starting element's index.
  length | The new view's length, from starting element. If 0, it will default to current view's ending point.

Returns
  A new view, which memory will be from index, of size length.

## ◆ operator[]() [1/2]

template<typename T = unsigned char>

T& nkMemory::BufferView< T >::operator[] | ( | unsigned long long | index | ) |

Indexing operator.

Parameters

  index | The index of the element to index in the memory.

Returns
  A reference over requested element.

## ◆ operator[]() [2/2]

template<typename T = unsigned char>

const T& nkMemory::BufferView< T >::operator[] | ( | unsigned long long | index | ) | const

Indexing operator, const versioned.

Parameters

  index | The index of the element to index in the memory.

Returns
  A reference over requested element.

## ◆ operator=() [1/2]

template<typename T = unsigned char>

BufferView<T>& nkMemory::BufferView< T >::operator= | ( | const BufferView< T > & | other | ) |
| noexcept

Copy assignment operator.

Parameters

  other | The view to copy over.

## ◆ operator=() [2/2]

template<typename T = unsigned char>

BufferView<T>& nkMemory::BufferView< T >::operator= | ( | BufferView< T > && | other | ) |
| noexcept

Move assignment operator.

Parameters

  other | The view to move over.

## ◆ operator Buffer()

template<typename T = unsigned char>

nkMemory::BufferView< T >::operator Buffer | ( |  | ) | const

Automatic conversion operator to a binary Buffer. This operation will copy the content as-is, in a binary fashion.

## ◆ operator BufferCast< U >()

template<typename T = unsigned char>
template<typename U = T>

nkMemory::BufferView< T >::operator BufferCast< U > | ( |  | ) | const

Automatic conversion operator to a buffer cast of the same type. This operation will copy the content as-is, ready to be interprated as it was.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsMemory/Containers/BufferView.h